package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.StaffInfoEntity;
import com.topscore.uke.mvp.contractors.GetStaffInfoContractor;
import com.topscore.uke.mvp.model.GetTeamStaffInfoModel;
import com.topscore.uke.network.BaseResponse;

/**
 * Created by 71468 on 2017/10/18.
 */

public class GetStaffInfoPresenter implements GetStaffInfoContractor,GetStaffInfoContractor.Presenter, GetStaffInfoContractor.Listener {

    private View mView;
    private String role;
    private String userId;

    private Model model;

    public GetStaffInfoPresenter(View view,String role,String userId){
        this.mView = view;
        this.role = role;
        this.userId = userId;
        this.model = new GetTeamStaffInfoModel(this);
    }

    @Override
    public void getStaffInfo() {
        mView.onLoading("正在处理中");
        model.getInfo(userId,role);
    }

    @Override
    public void onError(int errorCode, String errorMessage) {
        mView.onFail(errorCode,errorMessage);
    }

    @Override
    public void onComplete() {
        mView.onLoadFinished();
    }

    @Override
    public void getInfoSuccess(BaseResponse<StaffInfoEntity> response) {
        mView.getInfoSuccess(response.getData());
    }
}
